package com.efun.sample.service;

import com.efun.sample.dao.PersonDao;
import com.efun.sample.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kinven on 17-8-15.
 */
@Service
@CacheConfig(cacheNames = "PersonService")
public class PersonServiceImpl implements PersonService {

    @Autowired
    private PersonDao personDao;

    public void setPersonDao(PersonDao personDao) {
        this.personDao = personDao;
    }

    @Cacheable(key="'select1'")
    public int select1(){
        return personDao.select1();
    }

    @CacheEvict(key = "'select1'")
    public List<Person> pageQueryPerson(int start,int size){
        return personDao.all(start,size);
    }

}
